/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package knowledgebase.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author eugene
 */
@Entity
@Table(name = "DOCUMENT_BLOCK")
public class DocumentBlock implements Serializable {
    
    private static final Long serialVersionUID = 9163151665456764L;
    
    @Id
    @Column(name = "DOC_BLOCK_ID")
    private String id;
    
    @Column(name = "BLOCK_DATA")
    private String data;
    
    @ManyToOne
    @JoinColumn(name = "DOC_ID")
    private Document parentDocument;
    
    @Column(name = "MODIFICATION_DATE")
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date modificationDate;
    
//    @Id
    @Column(name = "INNER_DOC_BLOCK_ID")
    private String innerId;

    @Column(name = "IS_CURRENT")
    private boolean current;

    public DocumentBlock() {
    }

    public DocumentBlock(String id, String data, Document parentDocument, Date modificationDate, String innerId, boolean current) {
        this.id = id;
        this.data = data;
        this.parentDocument = parentDocument;
        this.modificationDate = modificationDate;
        this.innerId = innerId;
        this.current = current;
    }

    public void setData(String data) {
        this.data = data;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setModificationDate(Date modificationDate) {
        this.modificationDate = modificationDate;
    }

    public void setParentDocument(Document parentDocument) {
        this.parentDocument = parentDocument;
    }

    public String getData() {
        return data;
    }

    public String getId() {
        return id;
    }

    public Date getModificationDate() {
        return modificationDate;
    }

    public Document getParentDocument() {
        return parentDocument;
    }
    
    public boolean isCurrent() {
        return current;
    }

    public void setCurrent(boolean current) {
        this.current = current;
    }

    public String getInnerId() {
        return innerId;
    }

    public void setInnerId(String innerId) {
        this.innerId = innerId;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof DocumentBlock) {
            if(((DocumentBlock) obj).getId().equals(this.id)) {
                return true;
            }
        }
        return false;
    }
    
}